
/**
\file Definition of nmn::math free functions.
\author Sean Tromans
*/

namespace nmn
{

	namespace math
	{

		//
		//	Vector
		//
		
		/**
		Calculates the scalar product between two vectors.
		@param lhs The first vector to use.
		@param rhs The second vector to use.
		@return The scalar product of lhs and rhs.
		\author Sean Tromans
		\relates nmn::math::vector
		*/
		template< typename TValueType, size_t Size >
		inline typename vector< TValueType, Size >::value_type dot( vector< TValueType, Size > const & lhs, vector< TValueType, Size > const & rhs )
		{
			float out = 0.0f;
			for ( size_t i = 0; i < Size; ++i )
			{
				out += lhs[i] * rhs[i];
			}

			return out;
		}

		//
		//	Matrix
		//

		/**
		Transposes a square_matrix.
		@param matrix The square_matrix to transpose.
		@return A transposed version of the provided matrix.
		\author Sean Tromans
		\relates nmn::math::square_matrix
		*/
		template< typename TValueType, size_t Size >
		inline square_matrix< TValueType, Size > transpose( square_matrix< TValueType, Size > matrix )
		{
			for ( size_t i = 1; i < matrix.size( ); ++i )
			{
				for ( size_t j = 0; j < i; ++j )
				{
					std::swap( matrix[i][j], matrix[j][i] );
				}
			}

			return matrix;
		}

	};

};

